package com.didi.gulimall.common.utils;

import java.util.Date;
import java.util.Random;

/**
 * @author 10626
 */
public class DateUtil {
    /**
     * 指定每天晚上12点过期
     *
     * @param currentTime
     * @return
     */
    public static Long cacheTime(Long currentTime) {
        Long oneDay = 86400000L;
//        60*1000L - 5*60*1000
        Long randomTime = Long.valueOf((60000 + Math.random() * (300000 - 60000 + 1)) + "");
        return currentTime + oneDay + randomTime;
    }

    /**
     * 比结束时间多5-10分钟时间
     *
     * @param date
     * @return
     */
    public static long getTime(Date date) {
        long time = date.getTime();
        long l = System.currentTimeMillis();
//        300000 -600000
        Random r = new Random();
        int v = r.nextInt(300000) + 300000;
        return time - l + v;
    }
}
